<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'userAdmin.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link type="text/css" rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function doit(flag,id)
{
	if(flag=="del")
	{
		if(confirm("确认删除吗？")!=true)
			return;
	}
}
$(function(){
	$("#list tr:not(:first)").remove();
	$.ajax({
		url:"findAllUser.action",
		type:"POST",
		success:function(data){
			for(var i=0;i<data.userList.length;i++){
				var user = data.userList[i];
				$("#list").append(" <tr><td>"+user.userId
				+"</td><td>"+user.userName
				+"</td><td>"+user.userSex
				+"</td><td>"+user.userAge
				+"</td><td>"+user.phone
				+"</td><td>"+user.address
				+"</td><td>"+user.authority
				+"</td></tr>");
			}
		}
	});

	$("#search").click(function(){
		var userName = $("#userName").val();
		$.ajax({
			url:"findUserByName.action",
			type:"POST",
			data:{"userName":userName},
			dataType:"json",
			success:function(data){
				$("#list tr:not(:first)").remove();
				for(var i=0;i<data.userList.length;i++){
					var user = data.userList[i];
					$("#list").append(" <tr><td>"+user.userId
					+"</td><td>"+user.userName
					+"</td><td>"+user.userSex
					+"</td><td>"+user.userAge
					+"</td><td>"+user.phone
					+"</td><td>"+user.address
					+"</td><td>"+user.authority
					+"</td></tr>");
				}
			}
		});
	});

});
</script>
  </head>
  
 <body>




<div class="menu">

<table>
<tbody><tr><td>
<c:if test="${sessionScope.currUser.authority == 1 }">

<input name="flag" value="search" class="input-text" type="hidden">
用户名称：<input name="userName" id="userName" class="input-text" type="text">&nbsp;&nbsp;&nbsp;&nbsp;
 <input value="查 询" type="submit" id="search">
</c:if>
</td></tr>
</tbody></table>
</div>
<div class="main">

<div class="optitle clearfix">
<em>
<c:if test="${sessionScope.currUser.authority == 1 }">

<input value="添加数据" class="input-button" onclick="window.location='userAdd.jsp'" type="button">
</c:if>
</em>
		<div class="title">用户管理&gt;&gt;</div>
	</div>
	<div class="content">
<table class="list" id="list">
  <tr>
    <td width="70" height="29"><div class="STYLE1" align="center">编号</div></td>
    <td width="80"><div class="STYLE1" align="center">用户名称</div></td>
    <td width="100"><div class="STYLE1" align="center">性别</div></td>
    <td width="100"><div class="STYLE1" align="center">年龄</div></td>

    <td width="150"><div class="STYLE1" align="center">电话 </div></td>
    <td width="150"><div class="STYLE1" align="center">地址 </div></td>
    <td width="150"><div class="STYLE1" align="center">权限 </div></td>
  </tr>
  
  
</table>
</div>
</div>
</body>
</html>
